const tagStore = {
  namespace: 'tag',
  state: () => ({
    tagsList: [
      {
        title: '仪表盘',
        fullPath: '/dashboard',
        path: '/dashboard',
        name: 'Home',
        query: {},
      },
      {
        title: '用户',
        fullPath: '/user',
        path: '/user',
        name: 'user',
        query: {},
      },
      {
        title: '角色',
        fullPath: '/role',
        path: '/role',
        name: 'role',
        query: {},
      },
      
    ],
    activeItem: "/user",
    mainItem: "/dashboard",
    preActiveItem: '/role'
  }),
  mutations: {
    delItem(state: any, payload: any) {
      state.tagsList = state.tagsList.filter((item:any) => item.path !== payload.path);
      state.activeItem = state.preActiveItem
      //state.mainItem = state.preActiveItem
      state.preActiveItem = '/dashboard';
    }
  },
  actions: {

  },
  getters: {
    tagsList(state: any) {
      const tags = state.tagsList.reduce((previousValue: any, currentValue: any) => {
        return previousValue.concat(currentValue);
      }, []);

      return tags;
    }
  }
}

export default tagStore;